<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('商品轮播图列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId" th:object="${StoreGoods}">
                    <div class="select-list">
                        <ul>
                            <li>
                                 <label>商品名称：</label>
                                 <input name="goodsId" th:field="*{goodsId}" id="goodsId" type="hidden"/>
                                 <input name="goodsName" th:field="*{goodsName}" disabled="disabled"/>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="add()" shiro:hasPermission="shop:image:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="shop:image:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('shop:image:edit')}]];
        var removeFlag = [[${@permission.hasPermi('shop:image:remove')}]];
        var prefix = ctx + "shop/image";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                queryParams: queryParams,
                modalName: "商品轮播图",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'image', 
                    title: '轮播图',
                    formatter: function(value, row, index) {
	                       return $.table.imageView(value,"200px");
	                 }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        function queryParams(params) {
			var search = $.table.queryParams(params);
			search.goodsId = $("#goodsId").val();
			return search;
		}
        function add() {
        	 var id = $("#goodsId").val();
		    $.operate.edit(id);
		}
    </script>
</body>
</html>